Socket
Socket
Sign inDemoInstall

merge2

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge2

Merge multiple streams into one stream in sequence or parallel.


Version published
Weekly downloads
37M
increased by1.02%
Maintainers
1
Weekly downloads
 
Created

What is merge2?

The merge2 npm package is a utility that allows you to merge multiple streams into a single stream in a sequential or parallel manner. It is useful for tasks such as combining file streams, merging async operations, or handling multiple sources of data in a unified way.

What are merge2's main functionalities?

Merging streams sequentially

This feature allows you to merge multiple streams one after the other. In the code sample, `stream1` and `stream2` are merged into a single stream `mergedStream`, which is then piped into a file. This is useful for combining files or data sequentially.

const merge2 = require('merge2');
const stream1 = fs.createReadStream('file1.txt');
const stream2 = fs.createReadStream('file2.txt');
const mergedStream = merge2(stream1, stream2);
mergedStream.pipe(fs.createWriteStream('combined.txt'));

Merging streams in parallel

This feature allows for merging streams in parallel and dynamically adding more streams. In the example, `stream1` and `stream2` are merged, and upon the end of `stream1`, `file3.txt` is added to the merge. This is useful for handling dynamic or asynchronous stream sources.

const merge2 = require('merge2');
const stream1 = fs.createReadStream('file1.txt');
const stream2 = fs.createReadStream('file2.txt');
const mergedStream = merge2([stream1, stream2], {end: false});
stream1.on('end', () => mergedStream.add(fs.createReadStream('file3.txt')));

Other packages similar to merge2

Keywords

FAQs

Package last updated on 03 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc